---
title: AI Engineers
description: 'Get started with Latitude using the TypeScript SDK'
---

This guide will walk you through integrating Latitude into your development workflow using our TypeScript SDK.

## Prerequisites

- A Latitude account (Sign up at [latitude.so](https://latitude.so) or use your self-hosted instance)
- Access to at least one AI provider (OpenAI, Anthropic, Google, etc.)
- Node.js (v16+) installed on your machine

## 1. Install and Initialize the SDK

```bash
# Install via npm
npm install @latitude-data/sdk

# Or via yarn
yarn add @latitude-data/sdk

# Or via pnpm
pnpm add @latitude-data/sdk
```

Initialize the SDK in your code:

```typescript
import { Latitude } from '@latitude-data/sdk'

const latitude = new Latitude('your_api_key')
// For self-hosted instances, specify options:
// const latitude = new Latitude('your_api_key', {
//   projectId: 123,
//   // Other options...
// })
```

## 2. Get or create a Prompt

```typescript
const prompt = await latitude.prompts.getOrCreate('/path/to/new/prompt', {
  prompt: {
    name: 'Customer Support Assistant',
    content: `
    ---
    provider: Latitude
    model: gpt-4o
    ---
    You are a helpful customer support assistant for a software company.
    
    Customer query: {{query}}
    Product: {{product}}
    
    Provide a helpful, friendly response that addresses the customer's question.
    Include relevant product details when necessary.`,
    provider: 'openai',
    // Other prompt properties as needed
  },
})
```

## 3. Fetch a Prompt

```typescript
const prompt = await latitude.prompts.get('/path/to/your/prompt')
```

## 4. Run a Prompt

```typescript
const response = await latitude.prompts.run('/path/to/your/prompt', {
  parameters: {
    query: 'How do I reset my password?',
    product: 'CloudManager Pro',
  },
})
```

## 5. Use Streaming Results and Logging

### Handling Streaming Responses

```typescript
const stream = await latitude.prompts.run('/path/to/your/prompt', {
  parameters: {
    query: 'How do I integrate your API?',
    product: 'Latitude SDK',
  },
  stream: true,
})

for await (const chunk of stream) {
  // Process text chunks
  if (chunk.type === 'text-delta' && chunk.content) {
    process.stdout.write(chunk.content)
  }
}
```

### Adding Custom Metadata for Logging

```typescript
const response = await latitude.prompts.run('/path/to/your/prompt', {
  parameters: {
    query: "What's new in version 2.0?",
    product: 'CloudManager Pro',
  },
  customIdentifier: 'user_query_123',
  onFinished: (data) => {
    console.log(`Run complete: ${data.uuid}`)
  },
})
```

## 6. Trigger Evaluations Programmatically

```typescript
const evaluation = await latitude.evaluations.trigger('conversation_uuid', {
  evaluationUuids: ['evaluation_uuid_1', 'evaluation_uuid_2'],
})
```

## Next Steps

Now that you've integrated Latitude into your code, you can:

- Explore additional SDK capabilities in the [SDK Reference](/guides/sdk/typescript)
- Learn about [Webhook integrations](/guides/api/webhooks) for event-driven workflows
- Set up [automatic logging](/guides/logs/overview) from various AI libraries
- Configure [custom API authentication](/guides/api/api-access) for your team
